from ._core import Model
from bson.objectid import ObjectId


class ModelHero(Model):
    def __init__(self, manage):
        super().__init__(manage=manage, db_name="hero", uni_key="_id", ver="local")

    async def addHero(self, uid: str, hid: int):
        heroInfo = {
            "uid": uid,
            "hid": hid,
            "lv": 1,
            "_id": str(ObjectId())
        }
        await self.insertOne(uid, heroInfo)

        return heroInfo

    async def getInfo(self, tid):
        """获取英雄数据"""
        return await self.get(tid)

    async def setInfo(self, uid, tid, set_data):
        """设置英雄数据"""
        return await self.set(uid, tid, set_data)

    async def getList(self, uid):
        """获取所有英雄数据"""
        return await self.gets(uid)
